<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="InstanceDetail.aspx.cs" Inherits="InstanceDetail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


    <table id="TableHeader" cellpadding="5" cellspacing="0" width="100%">
      <tr>
                <td bgcolor="#EBE7E7">
                <table width="100%">
                    <tr>
                                        <td>Instance Detail</td>
                                        <td align=right>
                                            &nbsp;<asp:LinkButton ID="btnLoadRepository" runat="server" OnClick="btnLoadRepository_Click" ForeColor="Blue">Collect Data Now</asp:LinkButton>
                                            &nbsp;<asp:LinkButton ID="lnkUpdate" runat="server" OnClick="lnkUpdate_Click" ForeColor="Green">Update Instance</asp:LinkButton>
                                            &nbsp;<asp:LinkButton ID="btnDelete" runat="server" OnClick="btnDelete_Click" ForeColor="Red">Delete Instance</asp:LinkButton>
                                        </td>
                                    </tr>
                </table>
                </td>
            </tr>
    </table>
    <table id="tbl1" cellpadding="0" cellspacing="0" width="100%">        
        <tr style="color: #000000">
                        <td>                        
                            <table cellpadding="5" cellspacing="0" id="TABLE1" width="100%">
                        <tr>
                        <td width=160px bgcolor="#EBE7E7">Instance Name:</td><td>
                <table cellpadding="5" cellspacing="0" width="100%">
                    <tr>
                        <td style="width: 50%; height: 18px;">
                            <asp:Label ID="txtInstanceName" runat="server" Font-Bold="True"></asp:Label>
                        </td>
                        <td style="width: 50%; height: 18px; text-align: right;">
                            <asp:HyperLink ID="lnkViewSystemProcesses" runat="server">View Process Info</asp:HyperLink>
                            </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">Short Description:</td>
            <td colspan="1">
                <asp:TextBox ID="txtShortDescription" runat="server" 
                    Font-Names="Arial" Width="600px"></asp:TextBox></td>
        </tr>
                                <tr>
                                    <td bgcolor="#EBE7E7" style="width: 160px">
                                        Primary Contact EMail:</td>
                                    <td colspan="1">
                                        <asp:TextBox ID="txtPrimaryContactEMail" runat="server" Width="475px"></asp:TextBox>
                                        &nbsp;
                                        <asp:HyperLink ID="lnkSendEMail" runat="server">Send EMail</asp:HyperLink>
                                    </td>
                                </tr>
                                <tr>
                                    <td bgcolor="#EBE7E7" style="width: 160px" valign="top">
                                        Monitoring Flags:</td>
                                    <td colspan="1">
                                        <asp:CheckBox ID="chkboxBusinessCritical" runat="server" AutoPostBack="True" 
                                            oncheckedchanged="chkboxBusinessCritical_CheckedChanged" 
                                            Text="Business Critical" />
                                        <br />
                                        <asp:CheckBox ID="chkboxDashBoardMonitored" runat="server" 
                                            Text="Enable Monitoring (Every 3 Minutes)" />
                                        <br />
                                        <asp:CheckBox ID="chkboxLoadIntoRepository" runat="server" 
                                            Text="Enable Detail Load (Every 3 Hours)" />                                        
                                    </td>
                                </tr>
                                <tr>
                                    <td bgcolor="#EBE7E7" style="width: 160px" valign="top">
                                        <asp:Label ID="lblBusinsessCriticalLevel" runat="server" 
                                            Text="Business Critical Level:"></asp:Label>
                                    </td>
                                    <td colspan="1">
                                        <asp:DropDownList ID="ddlBusinessCriticalLevel" runat="server" Width="500px" z-axis="900">
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr>
                                    <td bgcolor="#EBE7E7" style="width: 160px" valign="top">
                                        <asp:Label ID="lblBusinessCriticalReason" runat="server" 
                                            Text="Business Critical Reason"></asp:Label>
                                    </td>
                                    <td colspan="1">
                                        <asp:TextBox ID="txtBusinessCriticalReason" runat="server" Height="80px" 
                                            TextMode="MultiLine" Width="600px"></asp:TextBox>
                                    </td>
                                </tr>
        </table></td></tr>
    </table>
    <table id="tblConfiguration" cellpadding="0" cellspacing="1" width="100%">
        <tr>
                        <td bgcolor="#EBE7E7">
                            <table style="width: 100%" cellpadding=5 cellspacing=0>
                                <tr>
                                    <td>Properties/Configuration</td>
                                    <td style="text-align: right">
                                                                            <asp:LinkButton ID="btnViewConfiguration" runat="server" 
                                                                                onclick="btnViewConfiguration_Click">View</asp:LinkButton>
                                                                        </td>
                                </tr>
                            </table>
                         </td>
                    </tr>
        <tr style="color: #000000">
                        <td>
                        <div id="DivConfiguration" runat=server>
    <table cellpadding="5" cellspacing="1" width="100%">
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                Domain Name:</td>
            <td>
                <asp:Label ID="lblInstanceDomainName" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                Port Number:</td>
            <td>
                <asp:Label ID="lblPortNumber" runat="server"></asp:Label></td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                Is Virtual:</td>
            <td>
                <asp:Label ID="lblIsVirtual" runat="server"></asp:Label>
            </td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                Is Clustered:</td>
            <td>
                <asp:Label ID="lblIsClustered" runat="server" Font-Bold="False"></asp:Label></td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                OS Version</td>
            <td>
                <asp:Label ID="lblOSVersion" runat="server" Font-Bold="False"></asp:Label></td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                Architecture:</td>
            <td>
                <asp:Label ID="lblArchitecture" runat="server" Font-Bold="False"></asp:Label></td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px; ">
                SQL Server Edition:</td>
            <td>
                <asp:Label ID="lblEdition" runat="server" Font-Bold="False"></asp:Label></td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px; height: 1px;">
                SQL Server Version:</td>
            <td style="height: 1px">
                <asp:Label ID="lblVersion" runat="server" Font-Bold="False"></asp:Label></td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">Service Pack:</td>
            <td><asp:Label ID="lblProductLevel" runat="server" Font-Bold="False"></asp:Label></td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                SQL Server Collation:</td>
            <td>
                <asp:Label ID="lblCollation" runat="server" Font-Bold="False"></asp:Label></td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                Login Mode:</td>
            <td>
                <asp:Label ID="lblSQLLoginMode" runat="server" Font-Bold="False"></asp:Label></td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                Available Memory:</td>
            <td>
                <asp:Label ID="lblMemory" runat="server" Font-Bold="False"></asp:Label>
                </td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                Min/Max Memory:</td>
            <td>
                <asp:Label ID="lblMinMemory" runat="server" Font-Bold="False"></asp:Label>/<asp:Label 
                    ID="lblMaxMemory" runat="server" Font-Bold="False"></asp:Label>
            </td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                Trace Flags:</td>
            <td>
                <asp:Label ID="lblTraceFlags" runat="server" Font-Bold="False"></asp:Label>
                &nbsp;&nbsp;
                <asp:HyperLink ID="HyperLink2" runat="server" 
                    NavigateUrl="http://msdn.microsoft.com/en-us/library/ms188396.aspx" 
                    Target="_blank">more info</asp:HyperLink>
            </td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                SQLServer Account:</td>
            <td>
                <asp:Label ID="lblSQLServerServiceAccount" runat="server" Font-Bold="False"></asp:Label>
            </td>
        </tr>
        <tr>
            <td bgcolor="#EBE7E7" style="width: 160px">
                SQLAgent Account:</td>
            <td>
                <asp:Label ID="lblSQLAgentServiceAccount" runat="server" Font-Bold="False"></asp:Label>
            </td>
        </tr>
    </table>
    </div>
                        </td>
                    </tr>
        <tr style="color: #000000">
                        <td bgcolor="#EBE7E7">
                            <table style="width: 100%" cellpadding=5 cellspacing=0>
                                <tr>
                                    <td>
                                        Drive Usage</td>
                                                                        <td style="text-align: right">
                                                                            <asp:LinkButton ID="btnDriveUsage" runat="server" onclick="btnDriveUsage_Click">View</asp:LinkButton>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                    </tr>
        <tr style="color: #000000">
                        <td>
                            <div id="DivDriveUsage" runat=server>   
                                <asp:GridView ID="gvDriveSpaceUsage" runat="server" AllowSorting="False" CellPadding="4" 
                                ForeColor="#333333" GridLines="None" 
                                Width="100%" AutoGenerateColumns="false">
                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <Columns>
                                    <asp:BoundField DataField="DriveName" HeaderText="DriveName">
                                        <ItemStyle HorizontalAlign="Left" />
                                        <HeaderStyle HorizontalAlign="Left" />
                                    </asp:BoundField>                                    
                                    <asp:BoundField DataField="DriveSizeGB" HeaderText="DriveSizeGB">
                                        <ItemStyle HorizontalAlign="Left" />
                                        <HeaderStyle HorizontalAlign="Left" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="DriveFreeSpaceGB" HeaderText="DriveFreeSpaceGB">
                                        <ItemStyle HorizontalAlign="Left" />
                                        <HeaderStyle HorizontalAlign="Left" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="DriveFreeSpacePct" HeaderText="DriveFreeSpacePct">
                                        <ItemStyle HorizontalAlign="Left" />
                                        <HeaderStyle HorizontalAlign="Left" />
                                    </asp:BoundField>
                                </Columns>
                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                <EditRowStyle BackColor="#999999" />
                                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                <HeaderStyle BackColor="#003366" Font-Bold="True" Font-Size="X-Small" 
                                    ForeColor="White" HorizontalAlign="Left" />
                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                            </asp:GridView>
                            </div>
                        </td>
                    </tr>
    </table>
    <table id="tblDatabase" cellpadding="0" cellspacing="1" width="100%">
                    <tr>
                        <td bgcolor="#EBE7E7">
                            <table style="width: 100%" cellpadding=5 cellspacing=0>
                                <tr>
                                    <td>Database Detail &nbsp;</td>
                                    <td style="text-align: right; height: 18px;">
                                        <asp:LinkButton ID="btnViewDatabases" runat="server" 
                                            onclick="btnViewDatabases_Click">View</asp:LinkButton>
                                                                        </td>
                                </tr>
                            </table>
                            </td>
                    </tr>
                    <tr style="color: #000000">
                        <td>
                        <div id="DivDatabases" runat=server>
                <asp:GridView ID="gv" runat="server" AutoGenerateColumns="False"
        CellPadding="4" DataKeyNames="InstanceName, DatabaseName" ForeColor="#333333"
        GridLines="None" Width="100%">
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <Columns>
            <asp:HyperLinkField DataNavigateUrlFields="InstanceName,DatabaseName" DataNavigateUrlFormatString="~/DatabaseDetail.aspx?InstanceName={0}&DatabaseName={1}"
                DataTextField="DatabaseName" HeaderText="Database Name" >
                <ItemStyle HorizontalAlign="Left" />
                <HeaderStyle HorizontalAlign="Left" />
            </asp:HyperLinkField>
            <asp:BoundField DataField="TotalSizeMB" HeaderText="TotalSize(MB)" >
                <ItemStyle HorizontalAlign="Left" />
                <HeaderStyle HorizontalAlign="Left" />
            </asp:BoundField>
            <asp:BoundField DataField="DataSizeMB" HeaderText="DataSize(MB)" >
                <ItemStyle HorizontalAlign="Left" />
                <HeaderStyle HorizontalAlign="Left" />
            </asp:BoundField>
            <asp:BoundField DataField="LogSizeMB" HeaderText="LogSize(MB)" >
            <ItemStyle HorizontalAlign="Left" />
                <HeaderStyle HorizontalAlign="Left" />
            </asp:BoundField>
            <asp:BoundField DataField="DataSpaceAvailableMB" HeaderText="DataSpaceAvailable(MB)" >
            <ItemStyle HorizontalAlign="Left" />
                <HeaderStyle HorizontalAlign="Left" />
            </asp:BoundField>
            <asp:BoundField DataField="DataSpaceAvailablePct" HeaderText="DataSpaceAvailable(Pct)" >
            <ItemStyle HorizontalAlign="Left" />
                <HeaderStyle HorizontalAlign="Left" />
            </asp:BoundField>
         </Columns>
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <EditRowStyle BackColor="#999999" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#003366" Font-Bold="True" Font-Size="X-Small" ForeColor="White" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:GridView></div></td></tr>
    </table>       
    <table id="tblJobs" cellpadding="0" cellspacing="1" width="100%">
    <tr>
        <td bgcolor="#EBE7E7">
         <table style="width: 100%" cellpadding=5 cellspacing=0>
          <tr>
            <td style="width: 186px; height: 18px;">Scheduled Jobs</td>
            <td style="text-align: right; height: 18px;"><asp:LinkButton ID="btnViewJobs" runat="server" onclick="btnViewJobs_Click"><span style="color: #003366">View</span></asp:LinkButton></td>
          </tr>
         </table>
        </td>
    </tr>
    </table>
    <div id="divJobs" runat=server>  
    <table width="100%"> 
    <tr>
     <td>      
      <asp:GridView ID="gvJobs" runat="server" AutoGenerateColumns="false" 
    CellPadding="4" ForeColor="#333333" GridLines="None" 
    Width="100%" onrowdatabound="gvJobs_RowDataBound">
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    <EditRowStyle BackColor="#999999" />
    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
    <HeaderStyle BackColor="#003366" Font-Bold="True" Font-Size="X-Small" 
        ForeColor="White" HorizontalAlign="Left" />
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    <Columns>
    <asp:HyperLinkField DataNavigateUrlFields="InstanceName,job_id" DataNavigateUrlFormatString="~/JobDetail.aspx?InstanceName={0}&Jobid={1}" DataTextField="jobname" HeaderText="jobname" >
            <ItemStyle HorizontalAlign="Left" />
            <HeaderStyle HorizontalAlign="Left" />
        </asp:HyperLinkField>
        <asp:BoundField DataField="enabled" HeaderText="enabled" >
            <ItemStyle HorizontalAlign="Left" />
            <HeaderStyle HorizontalAlign="Left" />
        </asp:BoundField>
        <asp:BoundField DataField="lastrun" HeaderText="lastrun" >
            <ItemStyle HorizontalAlign="Left" />
            <HeaderStyle HorizontalAlign="Left" />
        </asp:BoundField>
        <asp:BoundField DataField="status" HeaderText="status" >
            <ItemStyle HorizontalAlign="Left" />
            <HeaderStyle HorizontalAlign="Left" />
        </asp:BoundField>
        <asp:BoundField DataField="duration" HeaderText="duration" >
            <ItemStyle HorizontalAlign="Left" />
            <HeaderStyle HorizontalAlign="Left" />
        </asp:BoundField>
    </Columns>
</asp:GridView>
     </td>
    </tr>
    </table> 
    </div>   
    <table id="tblNotes" runat=server cellpadding="0" cellspacing="1" width="100%">
         <tr>
                                    <td bgcolor="#EBE7E7">
                                        <table style="width: 100%" cellpadding=5 cellspacing=0>
                                                <tr>
                                                    <td>Notes</td>
                                                    <td align="right"><asp:HyperLink ID="lnkAddNote" runat="server">Add Note</asp:HyperLink></td>
                                                </tr>
                                        </table>
                                    </td>
                                </tr>
        <tr style="color: #000000">
                                    <td>
                                        <asp:SqlDataSource ID="DS" runat="server" ConnectionString="<%$ ConnectionStrings:Application_Data %>" 
                                       SelectCommand="SELECT InstanceNoteID,CreatedBy,convert(char(10),CreateDate,101) as CreateDate,Note FROM InstanceNote Where InstanceName = @InstanceName"
                                       DeleteCommand="DELETE FROM InstanceNote Where InstanceNoteID = @InstanceNoteID">     
                        <SelectParameters>
                            <asp:QueryStringParameter Name="InstanceName" QueryStringField="InstanceName" Type="Object"/>
                        </SelectParameters>   
                        <DeleteParameters>
                            <asp:Parameter Name="InstanceNoteID" Type="Int32" />
                        </DeleteParameters>               
                    </asp:SqlDataSource>                    
                            <asp:GridView id="GridView1" DataKeyNames="InstanceNoteID" runat="server" 
                                AutoGenerateColumns="false" CellPadding="4" DataSourceID="DS"
                                ForeColor="#333333" GridLines="None" Width="100%" Height="100%">
                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                <EditRowStyle BackColor="#999999" />
                                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                <HeaderStyle BackColor="#003366" Font-Bold="True" Font-Size="X-Small" ForeColor="White"
                                    HorizontalAlign="Left" />
                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                <Columns>
                                    <asp:BoundField DataField="Note" HeaderText="Note" >
                                        <ItemStyle HorizontalAlign="Left" Width=70% />
                                        <HeaderStyle HorizontalAlign="Left" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="CreatedBy" HeaderText="CreatedBy" >
                                        <ItemStyle HorizontalAlign="Left" Width=10% />
                                        <HeaderStyle HorizontalAlign="Left" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="CreateDate" HeaderText="Date" >
                                        <ItemStyle HorizontalAlign="Left" Width=10% />
                                        <HeaderStyle HorizontalAlign="Left" />
                                    </asp:BoundField>
                                    <asp:CommandField DeleteText="Delete" ShowDeleteButton="True">
                                    <ItemStyle HorizontalAlign="Right" Width=10% />
                                    </asp:CommandField>
                                </Columns>
                            </asp:GridView>
                                    </td>
                                </tr>
    </table>
</asp:Content>

